import { SuiClient, getFullnodeUrl } from "@mysten/sui/client";

// Get all balances of coins in an account

async function getAccountBalances(address: string) {
  // Initialize an instance of `SuiClient`
  const fullNodeUrl = getFullnodeUrl("mainnet");
  const client = new SuiClient({ url: fullNodeUrl });

  // Get balances of tokens of an account
  const balance = await client.getAllBalances({
    owner: address,
  });

  return balance;
}

const account =
  "0x784aeb9820c266e80b480ad3d4e9b54cbcdaecfc53f64d45f8390bd4733d299d";
getAccountBalances(account).then(console.log).catch(console.error);
